/*
 * @Author: your name
 * @Date: 2024-11-10 12:18:33
 * @LastEditTime: 2024-11-10 12:27:00
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \.leetcode\540.有序数组中的单一元素.cpp
 */
/*
 * @lc app=leetcode.cn id=540 lang=cpp
 *
 * [540] 有序数组中的单一元素
 */

// @lc code=start
class Solution {
public:
    int singleNonDuplicate(vector<int>& nums) {
        int low = 0, high = nums.size() - 1;
        while (low < high) {
            int mid = (high - low) / 2 + low;
            if (nums[mid] == nums[mid ^ 1]) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        return nums[low];
    }

// 作者：力扣官方题解
// 链接：https://leetcode.cn/problems/single-element-in-a-sorted-array/solutions/1252764/you-xu-shu-zu-zhong-de-dan-yi-yuan-su-by-y8gh/
// 来源：力扣（LeetCode）
// 著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。
//     }
};
// @lc code=end

